//
//  KTRootTabBatVC.swift
//  KTDouYu
//
//  Created by CoolKi on 16/5/4.
//  Copyright © 2016年 CoolKi. All rights reserved.
//

import UIKit

class KTRootTabBatVC: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        //创建 四个字控制器
        //推荐
        let recommendVC = RecommendViewController()
        self.add_KTChildViewController(recommendVC, title: "推荐", imgName: "home", imgSelectName: "home_click")
        
        //栏目
        let programaVC = ProgramaViewController()
        self.add_KTChildViewController(programaVC, title: "栏目", imgName: "game", imgSelectName: "game_click")
        
        //直播
        let liveVC = LiveViewController()
        self.add_KTChildViewController(liveVC, title: "直播", imgName: "live", imgSelectName: "live_click")
        
        //我的
        let mineVC = MineViewController()
        self.add_KTChildViewController(mineVC, title: "我的", imgName: "userman", imgSelectName: "userman_click")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func add_KTChildViewController(childVC:UIViewController,title:String,imgName:String,imgSelectName:String){
        //tabbarItem 是模型 是tabbarController下面按钮的数据模型
        let navigationControlle = BaseNavController(rootViewController: childVC)
        navigationControlle.tabBarItem.title = title
        navigationControlle.tabBarItem.image = UIImage(named: imgName)
        navigationControlle.tabBarItem.selectedImage = UIImage(named: imgSelectName)!.imageWithRenderingMode(.AlwaysOriginal)
        self.addChildViewController(navigationControlle)
    }
    
    override class func initialize(){
        
        let tabBarItem = UITabBarItem.appearance()
        let attributeDic : [String : AnyObject] = [NSForegroundColorAttributeName : UIColor.kt_colorWithHexString("f56f22", alpha: 1)]
        tabBarItem.setTitleTextAttributes(attributeDic, forState:.Selected)
        
    }
}








